/*
 * @Descripttion: $0
 * @version: 
 * @Author: linPing
 * @Date: 2019-10-29 01:26:12
 * @LastEditTime: 2019-11-02 11:16:05
 */
import {createSwitchNavigator,createAppContainer }  from 'react-navigation'
import { createStackNavigator}  from 'react-navigation-stack'
import WelcomePage from '../page/WelcomePage'
import LoginPage from '../page/LoginPage'
import IndexPage from '../page/IndexPage'
import DetailPage from '../page/DetailPage'
import WebViewPage from '../page/WebViewPage'
import AboutPage from '../page/about/AboutPage'

import TaskPage from '../page/task/TaskPage' // 任务页面
import TaskDetailPage from '../page/task/TaskDetailPage' // 任务详情页面
import TaskRoomList from '../page/task/TaskRoomList' // 任务房间列表
import TaskRoomDetail from '../page/task/TaskRoomDetail' // 检查记录详情
import TaskCheck from '../page/task/TaskCheck' // 检查页面

//common
import PhotoBrowserScene from '../page/PhotoBrowserScene' // 显示大图
import ShowDataPage from '../page/demo/ShowDataPage' // 临时页面显示data数据
import TreeSelect from '../common/TreeSelect' // 检查页面


const InitNavigator = createStackNavigator({
    WelcomePage:{
        screen:WelcomePage,
        navigationOptions:{
            header:null
        }
    }
},{
    defaultNavigationOptions:{
        header:null
    }
})


const LoginNavigator = createStackNavigator({
    LoginPage:{
        screen:LoginPage,
        navigationOptions:{
            header:null
        }
    }
},{
    defaultNavigationOptions:{
        header:null
    }
})

const MainNavigator = createStackNavigator({
    IndexPage:{
        screen:IndexPage,
        navigationOptions:{
            header:null
        }
    },
    TreeSelect:{
        screen:TreeSelect,
        navigationOptions:{
            header:null
        }
    },
    ShowDataPage:{
        screen:ShowDataPage,
        navigationOptions:{
            header:null
        }
    },
    DetailPage:{
        screen:DetailPage,
        navigationOptions:{
            header:null
        }
    },
      PhotoPage:{
        screen:PhotoBrowserScene,
        navigationOptions:{
            header:null
        }
    },
    WebViewPage: {
        screen: WebViewPage,
        navigationOptions: {
            header: null,// 可以通过将header设为null 来禁用StackNavigator的Navigation Bar
        }
    },
    TaskPage: {
        screen: TaskPage,
        navigationOptions: {
            header: null,
        }
    },
    TaskDetailPage: {
        screen: TaskDetailPage,
        navigationOptions: {
            header: null,
        }
    },
    TaskRoomList: {
        screen: TaskRoomList,
        navigationOptions: {
            header: null,
        }
    },
    TaskRoomDetail: {
        screen: TaskRoomDetail,
        navigationOptions: {
            header: null,
        }
    },
    TaskCheck: {
        screen: TaskCheck,
        navigationOptions: {
            header: null,
        }
    },
    AboutPage: {
        screen: AboutPage,
        navigationOptions: {
            header: null,
        }
    },
    // FetchDemoPage:{
    //     screen:FetchDemoPage,
    //     navigationOptions:{
        
    //     }
    // },
    // AsyncStorageDemoPage:{
    //     screen:AsyncStorageDemoPage,
    //     navigationOptions:{
    //         title:'AsyncStorageDemoPage'
        
    //     }
    // },
    // DataStoreDemoPage:{
    //     screen:DataStoreDemoPage,
    //     navigationOptions:{
    //         title:'DataStoreDemoPage'
        
    //     }
    // }
})

const AppNavigator = createSwitchNavigator({
    Init:InitNavigator,
    Login:LoginNavigator,
    Main:MainNavigator
},{
    navigationOptions:{
        header:null
    }
})
export const rootCom = 'Init';//设置根路由
export const RootNavigator =  createAppContainer(AppNavigator)


/** 
 * 1.初始化react-navigation与redux的中间件， 
 * 该方法的一个很大的作用就是为reduxifyNavigator的key设置actionSubscribers(行为订阅者) 
 * 设置订阅者@https://github.com/react-navigation/react-navigation-redux-helpers/blob/master/src/middleware.js#L29 
 * 检测订阅者是否存在@https://github.com/react-navigation/react-navigation-redux-helpers/blob/master/src/middleware.js#L97 
 * @type {Middleware} 
 **/
// export const middleware = createReactNavigationReduxMiddleware(
//     state => state.nav,
//     'root'
// );
 
/** 2.将根导航器组件传递给 createReduxContainer 函数, 
 *  并返回一个将navigation state 和 dispatch 函数作为 props的新组件；
 * 注意：要在createReactNavigationReduxMiddleware之后执行
//  **/
// const AppWithNavigationState = createReduxContainer(RootNavigator, 'root');

// /** * State到Props的映射关系 * @param state */
// const mapStateToProps = state => ({
//     state: state.nav,//v2
// });
/** * 3.连接 React 组件与 Redux store */
// export default connect(mapStateToProps)(AppWithNavigationState);
export default RootNavigator